package com.codefish.framework.spring.beans.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

/**
 * @author <a href='https://gitee.com/hzf2281'>codefish</a>
 * @version 1.0.0
 * @since 2022/11/07 上午 11:10
 */
public class DependencyDescriptor {
    //-------通用属性-------

    private boolean required;
    private boolean isField;


    //------包装的依赖项为Field-------
    private Field field;

    //------TODO 包装的依赖项为Method-------


    public DependencyDescriptor(Field field, boolean required) {
        this.field = field;
        this.required = required;
        this.isField = true;
    }

    public Class<?> getDependencyType() {
        if (isField && field != null) {
            return field.getType();
        }
        return null;
    }

    public Annotation[] getAnnotations() {
        if (isField && field != null) {
            return field.getAnnotations();
        }
        return new Annotation[0];
    }

}
